package com.cdz.charger.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cdz.charger.vo.FeedbackVo;
import com.cdz.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cdz.common.annotation.Log;
import com.cdz.common.core.controller.BaseController;
import com.cdz.common.core.domain.AjaxResult;
import com.cdz.common.enums.BusinessType;
import com.cdz.charger.domain.Feedback;
import com.cdz.charger.service.IFeedbackService;
import com.cdz.common.utils.poi.ExcelUtil;
import com.cdz.common.core.page.TableDataInfo;

/**
 * 用户反馈Controller
 *
 * @author baefengk2
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/charger/feedback" )
@Api(tags = "用户反馈相关接口" )
public class FeedbackController extends BaseController {
    @Autowired
    private IFeedbackService feedbackService;

    /**
     * 查询用户反馈列表
     */
    @PreAuthorize("@ss.hasPermi('charger:feedback:list')" )
    @GetMapping("/list" )
    @ApiOperation(value = "获取用户反馈列表" )
    public TableDataInfo<List<FeedbackVo>> list(Feedback feedback) {
        startPage();
        List<FeedbackVo> list = feedbackService.selectFeedbackList(feedback);
        return getDataTable(list);
    }


    /**
     * 获取用户反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('charger:feedback:query')" )
    @GetMapping(value = "/{id}" )
    @ApiOperation("获取用户反馈详细信息" )
    public R<Feedback> getInfo(@ApiParam(value = "用户反馈ID" , required = true)
                                   @PathVariable("id" ) Long id) {
                return R.ok(feedbackService.selectFeedbackById(id));
    }

    /**
     * 新增用户反馈
     */
    @PreAuthorize("@ss.hasPermi('charger:feedback:add')" )
    @Log(title = "用户反馈" , businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增用户反馈" )
    public AjaxResult add(@ApiParam(value = "用户反馈实体" , required = true) @RequestBody Feedback feedback) {
        return toAjax(feedbackService.insertFeedback(feedback));
    }

    /**
     * 修改用户反馈
     */
    @PreAuthorize("@ss.hasPermi('charger:feedback:edit')" )
    @Log(title = "用户反馈" , businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改用户反馈" )
    public AjaxResult edit(@ApiParam(value = "用户反馈实体" , required = true) @RequestBody Feedback feedback) {
        return toAjax(feedbackService.updateFeedback(feedback));
    }

    /**
     * 删除用户反馈
     */
    @PreAuthorize("@ss.hasPermi('charger:feedback:remove')" )
    @Log(title = "用户反馈" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    @ApiOperation("删除用户反馈" )
    public AjaxResult remove(@ApiParam(value = "要删除的数据id的数组" ) @PathVariable Long[] ids) {
        return toAjax(feedbackService.deleteFeedbackByIds(ids));
    }
}
